using System;
using System.Data;
using System.Data.SqlClient;
namespace CommandLib.Base
{
	public class MyDataReader : IDataReader, IDisposable, IDataRecord
	{
		private IDataReader _dataReader;
		private bool _disposedValue;
		protected IDataReader DataReader
		{
			get
			{
				return this._dataReader;
			}
		}
		public int Depth
		{
			get
			{
				return this._dataReader.Depth;
			}
		}
		public int FieldCount
		{
			get
			{
				return this._dataReader.FieldCount;
			}
		}
		public bool IsClosed
		{
			get
			{
				return this._dataReader.IsClosed;
			}
		}
		public object this[string name]
		{
			get
			{
				object obj = this._dataReader[name];
				object result;
				if (DBNull.Value.Equals(obj))
				{
					result = null;
				}
				else
				{
					result = obj;
				}
				return result;
			}
		}
		public virtual object this[int i]
		{
			get
			{
				object result;
				if (this._dataReader.IsDBNull(i))
				{
					result = null;
				}
				else
				{
					result = this._dataReader[i];
				}
				return result;
			}
		}
		public int RecordsAffected
		{
			get
			{
				return this._dataReader.RecordsAffected;
			}
		}
		public MyDataReader(IDataReader dataReader)
		{
			this._dataReader = dataReader;
		}
		public TimeSpan GetTimeSpan(string name)
		{
			return this.GetTimeSpan(this._dataReader.GetOrdinal(name));
		}
		public TimeSpan GetTimeSpan(int i)
		{
			if (this._dataReader is SqlDataReader)
			{
				return ((SqlDataReader)this._dataReader).GetTimeSpan(i);
			}
			throw new Exception("The DataReader is not a SqlDataReader");
		}
		public string GetString(string name)
		{
			return this.GetString(this._dataReader.GetOrdinal(name));
		}
		public virtual string GetString(int i)
		{
			string result;
			if (this._dataReader.IsDBNull(i))
			{
				result = string.Empty;
			}
			else
			{
				result = this._dataReader.GetString(i);
			}
			return result;
		}
		public object GetValue(string name)
		{
			return this.GetValue(this._dataReader.GetOrdinal(name));
		}
		public virtual object GetValue(int i)
		{
			object result;
			if (this._dataReader.IsDBNull(i))
			{
				result = null;
			}
			else
			{
				result = this._dataReader.GetValue(i);
			}
			return result;
		}
		public int GetInt32(string name)
		{
			return this.GetInt32(this._dataReader.GetOrdinal(name));
		}
		public virtual int GetInt32(int i)
		{
			int result;
			if (this._dataReader.IsDBNull(i))
			{
				result = 0;
			}
			else
			{
				result = this._dataReader.GetInt32(i);
			}
			return result;
		}
		public double GetDouble(string name)
		{
			return this.GetDouble(this._dataReader.GetOrdinal(name));
		}
		public virtual double GetDouble(int i)
		{
			double result;
			if (this._dataReader.IsDBNull(i))
			{
				result = 0.0;
			}
			else
			{
				result = this._dataReader.GetDouble(i);
			}
			return result;
		}
		public Guid GetGuid(string name)
		{
			return this.GetGuid(this._dataReader.GetOrdinal(name));
		}
		public virtual Guid GetGuid(int i)
		{
			Guid result;
			if (this._dataReader.IsDBNull(i))
			{
				result = Guid.Empty;
			}
			else
			{
				result = this._dataReader.GetGuid(i);
			}
			return result;
		}
		public bool Read()
		{
			return this._dataReader.Read();
		}
		public bool NextResult()
		{
			return this._dataReader.NextResult();
		}
		public void Close()
		{
			this._dataReader.Close();
		}
		public bool GetBoolean(string name)
		{
			return this.GetBoolean(this._dataReader.GetOrdinal(name));
		}
		public virtual bool GetBoolean(int i)
		{
			return !this._dataReader.IsDBNull(i) && this._dataReader.GetBoolean(i);
		}
		public byte GetByte(string name)
		{
			return this.GetByte(this._dataReader.GetOrdinal(name));
		}
		public virtual byte GetByte(int i)
		{
			byte result;
			if (this._dataReader.IsDBNull(i))
			{
				result = 0;
			}
			else
			{
				result = this._dataReader.GetByte(i);
			}
			return result;
		}
		public long GetBytes(string name, long fieldOffset, byte[] buffer, int bufferOffset, int length)
		{
			return this.GetBytes(this._dataReader.GetOrdinal(name), fieldOffset, buffer, bufferOffset, length);
		}
		public virtual long GetBytes(int i, long fieldOffset, byte[] buffer, int bufferOffset, int length)
		{
			long result;
			if (this._dataReader.IsDBNull(i))
			{
				result = 0L;
			}
			else
			{
				result = this._dataReader.GetBytes(i, fieldOffset, buffer, bufferOffset, length);
			}
			return result;
		}
		public char GetChar(string name)
		{
			return this.GetChar(this._dataReader.GetOrdinal(name));
		}
		public virtual char GetChar(int i)
		{
			char result;
			if (this._dataReader.IsDBNull(i))
			{
				result = '\0';
			}
			else
			{
				char[] array = new char[1];
				this._dataReader.GetChars(i, 0L, array, 0, 1);
				result = array[0];
			}
			return result;
		}
		public long GetChars(string name, long fieldOffset, char[] buffer, int bufferOffset, int length)
		{
			return this.GetChars(this._dataReader.GetOrdinal(name), fieldOffset, buffer, bufferOffset, length);
		}
		public virtual long GetChars(int i, long fieldOffset, char[] buffer, int bufferOffset, int length)
		{
			long result;
			if (this._dataReader.IsDBNull(i))
			{
				result = 0L;
			}
			else
			{
				result = this._dataReader.GetChars(i, fieldOffset, buffer, bufferOffset, length);
			}
			return result;
		}
		public IDataReader GetData(string name)
		{
			return this.GetData(this._dataReader.GetOrdinal(name));
		}
		public virtual IDataReader GetData(int i)
		{
			return this._dataReader.GetData(i);
		}
		public string GetDataTypeName(string name)
		{
			return this.GetDataTypeName(this._dataReader.GetOrdinal(name));
		}
		public virtual string GetDataTypeName(int i)
		{
			return this._dataReader.GetDataTypeName(i);
		}
		public virtual DateTime GetDateTime(string name)
		{
			return this.GetDateTime(this._dataReader.GetOrdinal(name));
		}
		public virtual DateTime GetDateTime(int i)
		{
			DateTime result;
			if (this._dataReader.IsDBNull(i))
			{
				result = DateTime.MinValue;
			}
			else
			{
				result = this._dataReader.GetDateTime(i);
			}
			return result;
		}
		public decimal GetDecimal(string name)
		{
			return this.GetDecimal(this._dataReader.GetOrdinal(name));
		}
		public virtual decimal GetDecimal(int i)
		{
			decimal result;
			if (this._dataReader.IsDBNull(i))
			{
				result = 0m;
			}
			else
			{
				result = this._dataReader.GetDecimal(i);
			}
			return result;
		}
		public Type GetFieldType(string name)
		{
			return this.GetFieldType(this._dataReader.GetOrdinal(name));
		}
		public virtual Type GetFieldType(int i)
		{
			return this._dataReader.GetFieldType(i);
		}
		public float GetFloat(string name)
		{
			return this.GetFloat(this._dataReader.GetOrdinal(name));
		}
		public virtual float GetFloat(int i)
		{
			float result;
			if (this._dataReader.IsDBNull(i))
			{
				result = 0f;
			}
			else
			{
				result = this._dataReader.GetFloat(i);
			}
			return result;
		}
		public short GetInt16(string name)
		{
			return this.GetInt16(this._dataReader.GetOrdinal(name));
		}
		public virtual short GetInt16(int i)
		{
			short result;
			if (this._dataReader.IsDBNull(i))
			{
				result = 0;
			}
			else
			{
				result = this._dataReader.GetInt16(i);
			}
			return result;
		}
		public long GetInt64(string name)
		{
			return this.GetInt64(this._dataReader.GetOrdinal(name));
		}
		public virtual long GetInt64(int i)
		{
			long result;
			if (this._dataReader.IsDBNull(i))
			{
				result = 0L;
			}
			else
			{
				result = this._dataReader.GetInt64(i);
			}
			return result;
		}
		public virtual string GetName(int i)
		{
			return this._dataReader.GetName(i);
		}
		public int GetOrdinal(string name)
		{
			return this._dataReader.GetOrdinal(name);
		}
		public DataTable GetSchemaTable()
		{
			return this._dataReader.GetSchemaTable();
		}
		public int GetValues(object[] values)
		{
			return this._dataReader.GetValues(values);
		}
		public virtual bool IsDBNull(int i)
		{
			return this._dataReader.IsDBNull(i);
		}
		public virtual bool IsDBNull(string name)
		{
			int ordinal = this.GetOrdinal(name);
			return this.IsDBNull(ordinal);
		}
		public bool HasCol(string colName)
		{
			bool result;
			for (int i = 0; i < this.FieldCount; i++)
			{
				if (this.GetName(i) == colName)
				{
					result = true;
					return result;
				}
			}
			result = false;
			return result;
		}
		protected virtual void Dispose(bool disposing)
		{
			if (!this._disposedValue)
			{
				if (disposing)
				{
					this._dataReader.Dispose();
				}
			}
			this._disposedValue = true;
		}
		public void Dispose()
		{
			this.Dispose(true);
			GC.SuppressFinalize(this);
		}
		~MyDataReader()
		{
			this.Dispose(false);
		}
		public float GetSingle(string p)
		{
			throw new NotImplementedException();
		}
	}
}
